package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.pro.ProductionReport;
import com.qidianit.mes.pro.mapper.FeedbackMapper;
import com.qidianit.mes.pro.service.FeedbackService;
import com.qidianit.mes.pro.vo.FeedbackProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: shanzhe
 * @Date: 2025/9/26 - 16:25
 */
@Service
public class FeedbackServiceImpl implements FeedbackService {

    @Autowired
    private FeedbackMapper feedbackMapper;

    @Override
    public PageInfo<FeedbackProduct> queryProductionReportByMAnyTags(Integer pageNum, Integer pageSize, Integer reportType, String workflowName, String productionOrderCode, String productCode, String productionName, String reportName, String approverName,Integer status) {
       PageHelper.startPage(pageNum, pageSize);
        List<FeedbackProduct> productionReports = feedbackMapper.queryProductionReportByMAnyTags(reportType,workflowName,productionOrderCode,productCode,productionName,reportName,approverName,status);
       PageInfo<FeedbackProduct> productionReportPageInfo = new PageInfo<>(productionReports);
       return productionReportPageInfo;

    }

    @Override
    public int addProductionReport(ProductionReport productionReport) {
        return  feedbackMapper.addProductionReport(productionReport);
    }

    @Override
    public FeedbackProduct getProductionReportById(Long id) {
        return feedbackMapper.getProductionReportById(id);
    }

    @Override
    public int updateProductionReport(ProductionReport productionReport) {
        return feedbackMapper.updateProductionReport(productionReport);
    }

    @Override
    public int deleteProductionReportById(Long id) {
        return feedbackMapper.deleteProductionReportById(id);
    }

    @Override
    public int batchDeleteProductionReportByIds(List<Long> ids) {
        int sum = 0;
        for (Long id : ids) {
            sum += feedbackMapper.deleteProductionReportById(id);
        }
        if (sum == ids.size()) {
            return 1;
        }
        return 0;
    }
}
